package com.qys.livesMall.app.user.controller.sys;



import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qys.livesMall.app.user.model.dto.sys.HandselQueryDTO;
import com.qys.livesMall.app.user.model.vo.PlatformBalanceDetailVO;
import com.qys.livesMall.app.user.model.vo.UserAccountDetailVO;
import com.qys.livesMall.app.user.model.vo.sys.HandselVO;
import com.qys.livesMall.app.user.model.vo.sys.ProfitAndLossStatisticsVO;
import com.qys.livesMall.app.user.service.IH2AppUserBalanceLogService;
import com.qys.livesMall.common.result.R;
import com.qys.livesMall.finance.model.dto.AccountDdetailSearch;
import com.qys.livesMall.finance.model.dto.AccountDetailSearch;
import com.qys.livesMall.framework.view.BaseQuery;
import com.qys.livesMall.framework.view.QysPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户(平台)资金变动记录

 *
 * @author dp
 * @since 2023-04-24
 */
@RestController
@RequestMapping("/sys/app/user/balance/log")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Tag(name = "sys-app用户资金记录")
public class SysH2AppUserBalanceLogController {

    private final IH2AppUserBalanceLogService userBalanceLogService;

    /**
     * 用户资金记录
     * @param search
     * @return
     */
    @PostMapping("/page")
    @Operation(summary = "分页查询用户资金记录")
    public R<QysPage<UserAccountDetailVO>> page(@RequestBody AccountDdetailSearch search) {
        return R.ok(userBalanceLogService.page((search)));
    }

    /**
     * 平台资金记录
     * @param search
     * @return
     */
    @PostMapping("/platformPage")
    @Operation(summary = "平台资金记录")
    public R<QysPage<PlatformBalanceDetailVO>> platformPage(@RequestBody AccountDetailSearch search) {
        return R.ok(userBalanceLogService.platformList((search)));
    }

    @PostMapping("/handsel")
    @Operation(summary = "用户彩金")
    public R<IPage<HandselVO>> platformPage(@RequestBody HandselQueryDTO dto) {
        return R.ok(userBalanceLogService.handsel(dto));
    }

    @PostMapping("/profitAndLossStatistics")
    @Operation(summary = "用户盈亏")
    public R<IPage<ProfitAndLossStatisticsVO>> profitAndLossStatistics(@RequestBody BaseQuery query) {
        return R.ok(userBalanceLogService.profitAndLossStatistics(query));
    }
}
